<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="../../common/sessionValidate.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
  <head>
    <title>T_bussines_apply信息维护</title>
    <%@ include file="../../common/meta.jsp"%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <link rel="stylesheet" href="<%=basePath%>css/my-bootstrap.css" media="screen"  id="tuserskin">
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <script type="text/javascript" src="<%= basePath %>js/jquery.cookie.js"></script>
  </head>
  <style>
hr {
    margin-top:1px;
    border-bottom: 1px solid #1BBC9B;
}
  </style>
  <body>
  <form class="form-horizontal form-bordered form-row-strippe" name="ffAdd" id="ffAdd" mentod="post" role="form" data-toggle="validator" enctype="multipart/form-data">
  <div class="" style="margin-right:2px;padding-right:1px;">

   <!-------------------------- 面板  start--------------------------------->
	<div class="panel panel-primary" >
	  <div class="panel-heading clearfix"  id="addHeaderDiv">
	  </div>
	  <div class="panel-body">
           <div class="row" >
                <h5>&nbsp;&nbsp;基本信息</h5>
	            <hr>
            	<div class="col-xs-6"><!--start 换列-->
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> applyid</label>
                            <div class="col-xs-9">
                                <input id="applyid" name="applyid" type="text" class="form-control" placeholder="applyid" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> companyid</label>
                            <div class="col-xs-9">
                                <input id="companyid" name="companyid" type="text" class="form-control" placeholder="companyid" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> companyname</label>
                            <div class="col-xs-9">
                                <input id="companyname" name="companyname" type="text" class="form-control" placeholder="companyname" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> linkman</label>
                            <div class="col-xs-9">
                                <input id="linkman" name="linkman" type="text" class="form-control" placeholder="linkman" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> tel</label>
                            <div class="col-xs-9">
                                <input id="tel" name="tel" type="text" class="form-control" placeholder="tel" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext1</label>
                            <div class="col-xs-9">
                                <input id="ext1" name="ext1" type="text" class="form-control" placeholder="ext1" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext2</label>
                            <div class="col-xs-9">
                                <input id="ext2" name="ext2" type="text" class="form-control" placeholder="ext2" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext3</label>
                            <div class="col-xs-9">
                                <input id="ext3" name="ext3" type="text" class="form-control" placeholder="ext3" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext4</label>
                            <div class="col-xs-9">
                                <input id="ext4" name="ext4" type="text" class="form-control" placeholder="ext4" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext5</label>
                            <div class="col-xs-9">
                                <input id="ext5" name="ext5" type="text" class="form-control" placeholder="ext5" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> ext6</label>
                            <div class="col-xs-9">
                                <input id="ext6" name="ext6" type="text" class="form-control" placeholder="ext6" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">楼栋</label>
                            <div class="col-xs-9">
                                <input id="buildingname" name="buildingname" type="text" class="form-control" placeholder="buildingname" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">楼层</label>
                            <div class="col-xs-9">
                                <input id="floorno" name="floorno" type="text" class="form-control" placeholder="floorno" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
				<!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">房源名称</label>
                            <div class="col-xs-9">
                                <input id="housename" name="housename" type="text" class="form-control" placeholder="housename" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> area</label>
                            <div class="col-xs-9">
                                <input id="area" name="area" type="text" class="form-control" placeholder="area" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> fix</label>
                            <div class="col-xs-9">
                                <input id="fix" name="fix" type="text" class="form-control" placeholder="fix" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> basesaleprice</label>
                            <div class="col-xs-9">
                                <input id="basesaleprice" name="basesaleprice" type="text" class="form-control" placeholder="basesaleprice" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> applytype</label>
                            <div class="col-xs-9">
                                <input id="applytype" name="applytype" type="text" class="form-control" placeholder="applytype" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> channelname</label>
                            <div class="col-xs-9">
                                <input id="channelname" name="channelname" type="text" class="form-control" placeholder="channelname" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> channelid</label>
                            <div class="col-xs-9">
                                <input id="channelid" name="channelid" type="text" class="form-control" placeholder="channelid" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> creater</label>
                            <div class="col-xs-9">
                                <input id="creater" name="creater" type="text" class="form-control" placeholder="creater" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> creattime</label>
                            <div class="col-xs-9">
                                <input id="creattime" name="creattime" type="text" class="form-control" placeholder="creattime" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> updater</label>
                            <div class="col-xs-9">
                                <input id="updater" name="updater" type="text" class="form-control" placeholder="updater" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3"> updattime</label>
                            <div class="col-xs-9">
                                <input id="updattime" name="updattime" type="text" class="form-control" placeholder="updattime" />
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-xs-3">申请时间</label>
                            <div class="col-xs-9">
                                <input id="applytime" name="applytime" type="text" class="form-control" placeholder="applytime" />
                            </div>
                        </div>
                    </div>
				</div><!--end 换列-->
            </div><!--end row-->
       </div><!--end body-->

	   <div class="modal-footer bg-info " id='buttonDiv'>
	   </div>
    </div>
    <!--------------------------面板 end------------------------------------>
    
    <!-- 模态框（Modal）start -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="myModalMessDiv"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!-- 模态框（Modal）end -->
  </div>
  </form>
  </body>
</html>

<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!--<script src="<%=basePath%>js/jquery-1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrapValidator.js"></script>-->
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
<!-- <script src="<%=basePath%>js/additional-methods.min.js"></script> -->
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%= basePath %>js/tableSortTool.js" ></script>
<script src="<%= basePath %>js/calendar.js" ></script>
<script type="text/javascript">
//新增保存数据
function add() {
	$("#addSaveButton").attr("disabled", true);
	var url = "<%=basePath%>t_bussines_apply/saveT_bussines_apply?time="+Math.random();
	var postData = $("#ffAdd").serializeArray();
	//alert(postData);
    $.post(url, postData, function (data) {
    	//var data = $.parseJSON(data);
        if (data.result=="success") {
            //保存成功  1.关闭弹出层，
          	showSuccessTips("恭喜保存成功!", "提示");
          	history.goBack();
        }
        else {
            $("#addSaveButton").removeAttr("disabled");
        	//showErrorTips("保存数据失败!", "错误信息：");
        	$("#myModal").modal('show'); //hide;
            $("#myModalMessDiv").html("<font color='red'>对不起,保存数据失败，失败原因：" + data.info + "</font>");
        	return false;
        }
    }).error(function () {
        $("#addSaveButton").removeAttr("disabled");
       	//showErrorTips("保存数据失败!", "错误信息：");
        $("#myModal").modal('show'); //hide;
        $("#myModalMessDiv").html("<font color='red'>对不起,保存数据失败，失败原因：" + data.info + "</font>");
    });
}

//更新修改数据到后台
function edit(){
	$("#editSaveButton").attr("disabled", true);
	var url = "<%=basePath%>t_bussines_apply/updateT_bussines_apply?time="+Math.random();
	myEdit2(url);
}

//更新修改数据到后台并且启动工作流
function tjsh() {
    $("#editSaveButton").attr("disabled", true);
    $("#tjshSaveButton").attr("disabled", true);
    var url = "<%=basePath%>t_bussines_apply/tjshT_bussines_apply?time=" + Math.random();
    myCurdTjsh(url);
}
    
//初始化页面及校验
$().ready(function(){
	//1、初始化数据显示
	var name = "招商渠道";
	var optype ='<%=request.getParameter("oplx")%>';
	var id='<%=request.getParameter("id")%>';
	//alert("optype="+optype+";id="+id);
	if(optype=='add'){
		$("#ffAdd")[0].reset();/*重置表单*/
	    var basePath="<i class='icon-plus'></i>&nbsp;";
		setHeader2("新增"+name, basePath);//设置addHeaderDiv标题文字及按钮
		setButtonDivAdd2();//设置adddiv的 操作按钮
	}else if(optype=='edit'){
		var basePath="<i class='icon-pencil'></i>&nbsp;";
		setHeader2("修改"+name, basePath);//设置addHeaderDiv标题文字及按钮
		//setButtonDivEdit2();//设置adddiv的 操作按钮
		setButtonDivEdit4();//设置adddiv的 操作按钮
	   	var url = "<%=basePath%>t_bussines_apply/getT_bussines_apply?id="+id+"&time="+Math.random();
	    $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
	    	setValue(data);
	    	//alert($("#effect_date").val()+""+jsonDateFormat($("#effect_date").val()));
	    	//$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
	    });
	}else if(optype=='view'){
		var basePath="<i class='icon-eye-open'></i>&nbsp;";//设置addHeaderDiv标题文字及按钮
		setHeader2("查看"+name, basePath);
		setButtonDivView2();//设置adddiv的 操作按钮
	   	var url = "<%=basePath%>t_bussines_apply/getT_bussines_apply?id="+id+"&time="+Math.random();
	    $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
	    	setValue(data);
	    	//alert($("#effect_date").val()+""+jsonDateFormat($("#effect_date").val()));
	    	//$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
	    });
	    formReadOnly('ffAdd');//设置表单不可修改
	}

	//2、校验脚本初始化，start check
	$("#ffAdd").validate({
		submitHandler:function(form){
            //alert($("#opType").val());
            if($("#opType").val()=="add"){
            	add();
            }else if($("#opType").val()=="edit"){
            	edit();
            }
	    },
		rules: {
			applyid: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			companyid: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			companyname: {
			    //required: true,
			    maxlength: 256
    		},
			linkman: {
			    //required: true,
			    maxlength: 45
    		},
			tel: {
			    //required: true,
			    maxlength: 45
    		},
			ext1: {
			    //required: true,
			    maxlength: 1024
    		},
			ext2: {
			    //required: true,
			    maxlength: 45
    		},
			ext3: {
			    //required: true,
			    maxlength: 45
    		},
			ext4: {
			    //required: true,
			    maxlength: 45
    		},
			ext5: {
			    //required: true,
			    maxlength: 45
    		},
			ext6: {
			    //required: true,
			    maxlength: 45
    		},
			buildingname: {
			    //required: true,
			    maxlength: 45
    		},
			floorno: {
			    //required: true,
			    maxlength: 45
    		},
			housename: {
			    //required: true,
			    maxlength: 45
    		},
			area: {
			    //required: true,
			    maxlength: 45
    		},
			fix: {
			    //required: true,
			    maxlength: 45
    		},
			basesaleprice: {
			    //required: true,
                number: true,
			    //minlength: 1,
			    maxlength: 22
    		},
			applytype: {
			    //required: true,
			    maxlength: 45
    		},
			channelname: {
			    //required: true,
			    maxlength: 45
    		},
			channelid: {
			    //required: true,
                digits: true,
			    //minlength: 1,
			    maxlength: 11
    		},
			creater: {
			    //required: true,
			    maxlength: 45
    		},
			creattime: {
			    //required: true,
			    maxlength: 45
    		},
			updater: {
			    //required: true,
			    maxlength: 45
    		},
			updattime: {
			    //required: true,
			    maxlength: 45
    		},
			applytime: {
			    //required: true,
			    maxlength: 45
    		}
	    }, //end rules;
	    messages: {
			applyid: {
			    //required: " applyid不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> applyid最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			companyid: {
			    //required: " companyid不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> companyid最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			companyname: {
			    maxlength: "<font color='red'> companyname最大支持256位,输入的数据已经超过最大长度！</font>"
    		},
			linkman: {
			    maxlength: "<font color='red'> linkman最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			tel: {
			    maxlength: "<font color='red'> tel最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			ext1: {
			    maxlength: "<font color='red'> ext1最大支持1,024位,输入的数据已经超过最大长度！</font>"
    		},
			ext2: {
			    maxlength: "<font color='red'> ext2最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			ext3: {
			    maxlength: "<font color='red'> ext3最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			ext4: {
			    maxlength: "<font color='red'> ext4最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			ext5: {
			    maxlength: "<font color='red'> ext5最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			ext6: {
			    maxlength: "<font color='red'> ext6最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			buildingname: {
			    maxlength: "<font color='red'>楼栋最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			floorno: {
			    maxlength: "<font color='red'>楼层最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			housename: {
			    maxlength: "<font color='red'>房源名称最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			area: {
			    maxlength: "<font color='red'> area最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			fix: {
			    maxlength: "<font color='red'> fix最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			basesaleprice: {
			    //required: true,
                number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> basesaleprice最大支持22位,输入的数据已经超过最大长度！</font>"
    		},
			applytype: {
			    maxlength: "<font color='red'> applytype最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			channelname: {
			    maxlength: "<font color='red'> channelname最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			channelid: {
			    //required: " channelid不能为空！",
                digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
			    //minlength: "<font color='red'>最少输入1位！</font>",
			    maxlength: "<font color='red'> channelid最大支持11位，输入的数据已经超过最大长度！</font>"
    		},
			creater: {
			    maxlength: "<font color='red'> creater最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			creattime: {
			    maxlength: "<font color='red'> creattime最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			updater: {
			    maxlength: "<font color='red'> updater最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			updattime: {
			    maxlength: "<font color='red'> updattime最大支持45位,输入的数据已经超过最大长度！</font>"
    		},
			applytime: {
			    maxlength: "<font color='red'>申请时间最大支持45位,输入的数据已经超过最大长度！</font>"
    		}
	   } //end message;
   	}); //end validate;
}) //end funciton read;
</script>
